<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件1</title>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
    <script>
        var li = document.getElementsByTagName("li");
        for(var i=0;i<li.length;i++){
            (function (i) {
                li[i].addEventListener('click',function () {
                    console.log(i);
                },false)
            }(i))
        }
    </script>

</body>
</html>
